package blt.a3rd.map;

import android.content.Context;

/**
 * Created by xugaopan on 2016/3/16.
 */
public class MapSdk {
    public static MapSdk mapSdk;
    public static MapClient mapClient;

    public static MapSdk getMapSdk() {
        if (null != mapSdk) {
            return mapSdk;
        }
        synchronized (MapSdk.class) {
            if (mapSdk == null) {
                mapSdk = new MapSdk();
            }
        }
        return mapSdk;
    }

    public void initSdk(Context context) {
        if (null != mapClient) {
            return;
        }
        synchronized (MapSdk.class) {
            if (null == mapClient) {
                mapClient = new MapClient(context);
            }
        }
    }

    public void start() {
        if (null != mapClient) {
            mapClient.startLocation();
        }
    }

    public void stop() {
        if (null != mapClient) {
            mapClient.stopLocation();
        }
    }

    public void clearSdk() {
        synchronized (MapSdk.class) {
            if (mapSdk != null && mapClient != null) {
                mapClient.close();
                mapClient = null;
                mapSdk = null;
            }
        }
    }
}
